import openpyxl;

# 获取excel件
from webkey.Key import Key

excel = openpyxl.load_workbook('../data/search_testcase.xlsx')
# 获取所有的sheet页
sheets = excel.sheetnames
for sheet in sheets:
    sheet = excel[sheet]
    for values in sheet.values:
        if type(values[0]) is int:
            data = {'name': values[2], 'value': values[3], 'txt': values[4]}
            for key1 in list(data.keys()):
                if data[key1] is None:
                    del data[key1]
            print(data)

            # 基于关键字进行测试的执行
            if values[1] == 'open_browser':
                key = Key(**data)
            else:
                getattr(key, values[1])(**data)
